package array;

import java.util.Comparator;

public class Heap<T> {

	private T[] elems;
	private int size;
	private int last;
	private Comparator<T> comp;
	
	public Heap(Comparator<T> comp){
		this.comp = comp;
		last=0;
		elems = (T[]) new Object[100];
		size = 100;
	}
	
	public void add(T elem){
		if(size == last){
			realoca();
		}
		if(elem != null){
			elems[last] = elem;
			up(last);
			last++;
		}
	}
	
	private void up(int i) {
		// TODO 
		
	}
	

	private void down(int i) {
		// TODO Auto-generated method stub
		
	}

	private void realoca() {
		T newElems[] = (T[]) new Object[size + 100];
		for(int i = 0; i < size; i++){
			newElems[i] = elems[i];
		}
		elems = newElems;
		size += 100;
	}

	public T remove(){
		T elem = elems[0];
		if(elem != null){
			down(0);
		}	
		return elem;
	}
	


	public T lookHead(T elem){
		return elems[0];	
	}
	
}
